//	--------------------------------------------------------------------
//	Copyright(C) 2006,2007 Zhao Yukun. All rights reserved.
//	This file is a part of the Xeres system.
//	Xeres 2007
//	Contact : xeres.engine@gmail.com
//	$(reservedInfo)
//	$(reservedDeclaration)
//	--------------------------------------------------------------------
///	@file	<ITexture.h>
///	@path	~/src/graphics/
///	@date	2007/12/13
///	@desc	Generic texture interface.

#pragma once

#include "xeres.h"

#include "lib/math/pair.h"
#include "lib/math/rect.h"
#include "lib/math/box.h"

#include "graphics/DxHelpers.h"
#include "graphics/IDeviceResource.h"

struct IUnknown;

namespace xeres {

	// forward declaration
	class ISprite;

	// texture type
	enum TextureType
	{
		TEXTURE_NONE = 0 ,
		TEXTURE_1D ,
		TEXTURE_2D ,
		TEXTURE_3D ,
		TEXTURE_ENV ,
		TEXTURE_DEPTH ,
		TEXTURE_last
	};

	/*!
		\class	ITexture
		\brief	Generic texture interface.

		\sa IRenderer
	*/
	class ITexture : public IDeviceResource
	{
	public:

		/// \name Constructor & Destructor
		//@{

		/// \ctor
		ITexture( void );

		/// \dtor
		virtual ~ITexture( void );

		//@}

		DECL_IOBJECT_INTERFACE( ITexture , IDeviceResource );

	public:

		/// \name ITexture Interface
		//@{

		/*!
			\brief		Get texture type.
		*/
		virtual TextureType GetType( void ) = 0;

		/*! 
			\brief		Get texture format.
		*/
		virtual DXFormat GetFormat( void ) = 0;

		/*!
			\brief		Get texture size.
		*/
		virtual Pair<int> GetSize( void ) = 0;

		/*!
			\brief		Get texture depth.
		*/
		virtual size_t GetDepth( void ) = 0;

		/*! 
			\brief		Get texture can be write by CPU.
		*/
		virtual bool IsWritable( void ) = 0;

		/*! 
			\brief		Get texture can be read back by CPU.
		*/
		virtual bool IsReadable( void ) = 0;

		/*!
			\brief		Map texture for write.
		*/
		virtual bool Map( uint sub , ResourceMap& data ) = 0;

		/*!
			\brief		Map texture for read back.
		*/
		virtual bool ReadBack( uint sub , ResourceMap& data , bool readonly ) = 0;

		/*!
			\brief		Unmap texture.
		*/
		virtual bool Unmap( uint sub ) = 0;

		/*! 
			\brief		Update texture.
		*/
		virtual bool Update( uint sub , const Box<uint>& size , const byte * data , uint row_pitch , uint depth_pitch ) = 0;

		/*! 
			\brief		Get native interface of texture.
		*/
		virtual IUnknown * GetTextureInterface( void ) = 0;

		//@}
	};

} // namespace xeres
